import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../share/my_color.dart';
import 'package:fluttertoast/fluttertoast.dart';

class ShowToastWidget {
  //直接隐藏提示框
  static Future<bool?> cancelToast() async {
    return Fluttertoast.cancel();
  }

  //展示提示框
  static Future showToast({
    required String msg,
    Toast toastLength = Toast.LENGTH_SHORT,
    int timeInSecForIosWeb = 1,
    double? fontSize,
    ToastGravity gravity = ToastGravity.CENTER,
    Color backgroundColor = Colors.black45,
    Color textColor = MyColors.color_249_249_249,
    bool webShowClose = false,
    webBgColor: "linear-gradient(to right, #00b09b, #96c93d)",
    webPosition: "right",
    // Function(bool) didTap,
  }) async {
    if (fontSize == null) {
      fontSize = 14;
    }

    final future = await Fluttertoast.showToast(
      msg: msg,
      toastLength: toastLength,
      timeInSecForIosWeb: timeInSecForIosWeb,
      fontSize: fontSize,
      gravity: gravity,
      backgroundColor: backgroundColor,
      textColor: textColor,
      webBgColor: webBgColor,
      webPosition: webPosition,
      webShowClose: webShowClose,
    );
    return future;
  }
}
